Routing control method, network device, and controller

ABSTRACT

A routing control methodincludes: the network device obtains a route suppression request; determines the second routing entry; and sets a state of the second routing entry to a non-delivery state that is used to indicate that the second routing entry does not need to be delivered to a forwarding table, Wherein the network device has a first routing entry and a second routing entry, an address prefix of the first routing entry is a first address prefix, an address prefix of the second routing entry is a second address prefix, a network segment to which the second address prefix belongs is a subset of a network segment to which the first address prefix belongs, and a mask in the second address prefix is greater than a mask in the first address prefix

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.16/147,179 filed on Sep. 28, 2018, which is a continuation ofInternational Application No. PCT/CN2017/076963, filed on Mar. 16, 2017,which claims priority to Chinese Patent Application No. 201610204188.0,filed on Mar. 31, 2016. All of the aforementioned applications arehereby incorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present invention relate to the field ofcommunications technologies, and in particular, to a routing controlmethod, a network device, and a controller.

BACKGROUND

A forwarding device usually has a forwarding entry that is also referredto as a forwarding information base (FIB) entry. When forwarding apacket, the forwarding device matches a destination address of thepacket with an address prefix of a forwarding entry to obtain a matchedforwarding entry, and thereby determines a route of the packet based onthe matched forwarding entry.

Currently, the forwarding device usually determines a route according toa longest match rule. To be specific, the forwarding device selects aforwarding entry with a longest mask from the forwarding entry thatmatches the destination address, and determines the route of the packetbased on the forwarding entry with a longest mask.

However, the inventor finds, through research, that in some scenarios,the route that is of the packet and determined based on the forwardingentry with a longest mask is often not an optimal route. However,currently there is no routing control manner used to select a routecorresponding to a short mask.

SUMMARY

To resolve the foregoing technical problems, embodiments of the presentinvention provide a routing control method, a network device, and acontroller, so as to select, by suppressing a route corresponding to along mask, a route corresponding to a short mask.

In view of this, in the embodiments of the present invention, technicalsolutions used to resolve the technical problem are as follows:

According to a first aspect, an embodiment of the present inventionprovides a routing control method, where a network device has a firstrouting entry and a second routing entry, an address prefix of the firstrouting entry is a first address prefix, an address prefix of the secondrouting entry is a second address prefix, a network segment to which thesecond address prefix belongs is a subset of a network segment to whichthe first address prefix belongs, a mask in the second address prefix isgreater than a mask in the first address prefix, and the methodincludes:

obtaining, by a control module of the network device, a routesuppression request;

determining, by the control module, the second routing entry; and

setting, by the control module, a state of the second routing entry to anon-delivery state, where the non-delivery state is used to indicatethat the second routing entry does not need to be delivered to aforwarding table.

In a first possible implementation of the first aspect, the setting, bythe control module, a state of the second routing entry to anon-delivery state includes:

setting, by the control module, the second routing entry to an in-activestate, or setting the second routing entry to a rib-only state in anactive state.

With reference to the first aspect or the first possible implementationof the first aspect, in a second possible implementation of the firstaspect, the route suppression request is a Border Gateway Protocol BGPflow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, and the addressmatch is the first address prefix or the second address prefix; and

the setting, by the control module, a state of the second routing entryto a non-delivery state includes:

setting, by the control module, the state of the second routing entry tothe non-delivery state based on the suppression action.

With reference to the first aspect or the first possible implementationof the first aspect, in a third possible implementation of the firstaspect, the route suppression request is a configuration command, theconfiguration command carries an address match and a suppression actioncorresponding to the address match, and the address match is the firstaddress prefix or the second address prefix; and the setting, by thecontrol module, a state of the second routing entry to a non-deliverystate includes:

setting, by the control module, the state of the second routing entry tothe non-delivery state based on the suppression action.

With reference to the first aspect or the first possible implementationof the first aspect, in a fourth possible implementation of the firstaspect, before the setting, by the control module, a state of the secondrouting entry to a non-delivery state, the method further includes:

determining, by the control module, that the first routing entry is in adelivery state in an active state.

With reference to the fourth possible implementation of the firstaspect, in a fifth possible implementation of the first aspect, afterthe setting, by the control module, a state of the second routing entryto a non-delivery state, the method further includes:

delivering, by the control module, the first routing entry to theforwarding table.

With reference to the first aspect or the first possible implementationof the first aspect, in a sixth possible implementation of the firstaspect, the network device is a physical forwarding device, and thecontrol module is a control module of the physical forwarding device; orthe network device is a first virtual machine deployed on a generalphysical server, and the control module is a control module of the firstvirtual machine; or the network device includes a second virtual machinedeployed on a general physical server, and the control module is thesecond virtual machine.

According to a second aspect, an embodiment of the present inventionprovides a routing control method, where the method includes:

delivering, by a controller, a first routing entry and a second routingentry to a control module of a network device, where an address prefixof the first routing entry is a first address prefix, an address prefixof the second routing entry is a second address prefix, a networksegment to which the second address prefix belongs is a subset of anetwork segment to which the first address prefix belongs, and a mask inthe second address prefix is greater than a mask in the first addressprefix;

determining, by the controller, the second routing entry; and

sending, by the controller, a route suppression request to the controlmodule, where the route suppression request is used to instruct thecontrol module to set a state of the second routing entry to anon-delivery state, and the non-delivery state is used to indicate thatthe second routing entry does not need to be delivered to a forwardingtable.

In a first possible implementation of the second aspect, the routesuppression request is used to instruct the control module to set thesecond routing entry to an in-active state, or set the second routingentry to a rib-only state in an active state.

With reference to the second aspect or the first possible implementationof the second aspect, in a second possible implementation of the firstaspect, the route suppression request is a Border Gateway Protocol BGPflow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, the suppressionaction is used to instruct the control module to set the state of thesecond routing entry to the non-delivery state based on the suppressionaction, and the address match is the first address prefix or the secondaddress prefix.

With reference to the second aspect or the first possible implementationof the second aspect, in a third possible implementation of the firstaspect, the route suppression request is a configuration command, theconfiguration command carries an address match and a suppression actioncorresponding to the address match, the suppression action is used toinstruct the control module to set the state of the second routing entryto the non-delivery state based on the suppression action, and theaddress match is the first address prefix or the second address prefix.

With reference to the second aspect or the first possible implementationof the second aspect, in a fourth possible implementation of the firstaspect, the controller is a controller that has a dedicated hardwarestructure, a controller implemented by installing software on a generalphysical server, or a virtual machine deployed on a general physicalserver.

According to a third aspect, an embodiment of the present inventionprovides a network device, where the network device has a first routingentry and a second routing entry, an address prefix of the first routingentry is a first address prefix, an address prefix of the second routingentry is a second address prefix, a network segment to which the secondaddress prefix belongs is a subset of a network segment to which thefirst address prefix belongs, and a mask in the second address prefix isgreater than a mask in the first address prefix; and

the network device includes a control module, where the control moduleincludes an obtaining unit, a determining unit, and a setting unit,where

the obtaining unit is configured to obtain a route suppression request;

the determining unit is configured to determine the second routingentry; and

the setting unit is configured to set a state of the second routingentry to a non-delivery state, where the non-delivery state is used toindicate that the second routing entry does not need to be delivered toa forwarding table.

In a first possible implementation of the third aspect, the setting unitis specifically configured to: set the second routing entry to anin-active state, or set the second routing entry to a rib-only state inan active state.

With reference to the third aspect or the first possible implementationof the third aspect, in a second possible implementation of the thirdaspect, the route suppression request is a Border Gateway Protocol BGPflow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, and the addressmatch is the first address prefix or the second address prefix; and thesetting unit is specifically configured to set the state of the secondrouting entry to the non-delivery state based on the suppression action.

With reference to the third aspect or the first possible implementationof the third aspect, in a third possible implementation of the thirdaspect, the route suppression request is a configuration command, theconfiguration command carries an address match and a suppression actioncorresponding to the address match, and the address match is the firstaddress prefix or the second address prefix; and

the setting unit is specifically configured to set the state of thesecond routing entry to the non-delivery state based on the suppressionaction.

With reference to the third aspect or the first possible implementationof the third aspect, in a fourth possible implementation of the thirdaspect, the determining unit is further configured to: before thesetting unit sets the state of the second routing entry to thenon-delivery state, determine that the first routing entry is in adelivery state in an active state.

With reference to the fourth possible implementation of the thirdaspect, in a fifth possible implementation of the third aspect, thenetwork device further includes a delivery unit, where

the delivery unit is configured to deliver the first routing entry tothe forwarding table after the setting unit sets the state of the secondrouting entry to the non-delivery state.

With reference to the third aspect or the first possible implementationof the third aspect, in a sixth possible implementation of the thirdaspect, the network device is a physical forwarding device, and thecontrol module is a control module of the physical forwarding device; orthe network device is a first virtual machine deployed on a generalphysical server, and the control module is a control module of the firstvirtual machine; or the network device includes a second virtual machinedeployed on a general physical server, and the control module is thesecond virtual machine.

According to a fourth aspect, an embodiment of the present inventionprovides a controller, including a delivery unit, a determining unit,and a sending unit, where

the delivery unit is configured to deliver a first routing entry and asecond routing entry to a control module of a network device, where anaddress prefix of the first routing entry is a first address prefix, anaddress prefix of the second routing entry is a second address prefix, anetwork segment to which the second address prefix belongs is a subsetof a network segment to which the first address prefix belongs, and amask in the second address prefix is greater than a mask in the firstaddress prefix;

the determining unit is configured to determine the second routingentry; and

the sending unit is configured to send a route suppression request tothe control module, where the route suppression request is used toinstruct the control module to set a state of the second routing entryto a non-delivery state, and the non-delivery state is used to indicatethat the second routing entry does not need to be delivered to aforwarding table.

In a first possible implementation of the fourth aspect, the routesuppression request is used to instruct the control module to set thesecond routing entry to an in-active state, or set the second routingentry to a rib-only state in an active state.

With reference to the fourth aspect or the first possible implementationof the fourth aspect, in a second possible implementation of the thirdaspect, the route suppression request is a Border Gateway Protocol BGPflow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, the suppressionaction is used to instruct the control module to set the state of thesecond routing entry to the non-delivery state based on the suppressionaction, and the address match is the first address prefix or the secondaddress prefix.

With reference to the fourth aspect or the first possible implementationof the fourth aspect, in a third possible implementation of the thirdaspect, the route suppression request is a configuration command, theconfiguration command carries an address match and a suppression actioncorresponding to the address match, the suppression action is used toinstruct the control module to set the state of the second routing entryto the non-delivery state based on the suppression action, and theaddress match is the first address prefix or the second address prefix.

With reference to the fourth aspect or the first possible implementationof the fourth aspect, in a fourth possible implementation of the thirdaspect, the controller is a controller that has a dedicated hardwarestructure, a controller implemented by installing software on a generalphysical server, or a virtual machine deployed on a general physicalserver.

According to a fourth aspect, an embodiment of the present inventionprovides a network system, including any possible implementation of theforegoing network device and any possible implementation of theforegoing controller.

It can be learned from the foregoing technical solutions that, in theembodiments of the present invention, the network device has the firstrouting entry and the second routing entry, the address prefix of thefirst routing entry is the first address prefix, the address prefix ofthe second routing entry is the second address prefix, the mask in thesecond address prefix is greater than the mask in the first addressprefix, and the network segment to which the second address prefixbelongs is the subset of the network segment to which the first addressprefix belongs. After obtaining the route suppression request, thecontrol module of the network device can determine the second routingentry, and set the state of the second routing entry to the non-deliverystate to indicate that the second routing entry does not need to bedelivered to the forwarding table. A route corresponding to the secondrouting entry is a route corresponding to a long mask. Therefore, when apacket is to be forwarded, the route corresponding to the long mask isnot selected for the packet based on the second routing entry, so as toselect, by suppressing the route corresponding to the long mask, a routecorresponding to a short mask.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention more clearly, the following briefly describes the accompanyingdrawings required for describing the embodiments. Apparently, theaccompanying drawings in the following description show merely someembodiments of the present invention, and persons of ordinary skill inthe art may derive other drawings from these accompanying drawingswithout creative efforts.

FIG. 1 is a schematic diagram of packet routing in the prior art;

FIG. 2 is a schematic flowchart of a method embodiment according to anembodiment of the present invention;

FIG. 3 is a schematic structural diagram of a forwarding systemaccording to an embodiment of the present invention;

FIG. 4 is a schematic structural diagram of a forwarding scenarioaccording to an embodiment of the present invention;

FIG. 5 is a schematic structural diagram of another forwarding scenarioaccording to an embodiment of the present invention;

FIG. 6 is a schematic structural diagram of another forwarding scenarioaccording to an embodiment of the present invention;

FIG. 7 is a schematic flowchart of another method embodiment accordingto an embodiment of the present invention;

FIG. 8 is a schematic flowchart of another method embodiment accordingto an embodiment of the present invention;

FIG. 9 is a schematic diagram of packet routing according to anembodiment of the present invention;

FIG. 10 is a schematic structural diagram of an apparatus embodiment ofa network device according to an embodiment of the present invention;

FIG. 11 is a schematic structural diagram of an apparatus embodiment ofa controller according to an embodiment of the present invention;

FIG. 12 is a schematic structural diagram of an apparatus embodiment ofa network system according to an embodiment of the present invention;

FIG. 13 is a schematic structural diagram of another apparatusembodiment of a network device according to an embodiment of the presentinvention; and

FIG. 14 is a schematic structural diagram of another apparatusembodiment of a controller according to an embodiment of the presentinvention.

DESCRIPTION OF EMBODIMENTS

A routing table (also referred to as a RIB table) and a forwarding table(also referred to as a FIB table) are two types of tables commonly usedin a forwarding process. After calculating a routing table, a controlplane delivers an entry in the routing table to a forwarding table of aforwarding plane, to indicate forwarding of a packet. For example, Table1 shows the routing table calculated by the control plane.

TABLE 1 Address prefix Out- (Destin- Prece- bound ation/ dence Cost Flagbit Next hop interface Mask) (Pre) (Cost) (Flags) (Next hop) (Interface)Entry state 0.0.0.0/0 60  0 D 120.0.0.2 Port 1 Delivery state in anactive (Active) state 8.0.0.0/8 100  3 D 120.0.0.2 Port 1 Delivery statein an active state 9.0.0.0/8 10 80 D 20.0.0.2 Port 2 Delivery state inan active state 9.1.0.0/16 100  4 D 120.0.0.2 Port 3 Delivery state inan active state 20.0.0.0/8 0  0 D 20.0.0.1 Port 2 Delivery state in anactive state

After all entries in Table 1 are delivered to the forwarding plane, aforwarding table shown in Table 2 is obtained.

TABLE 2 Outbound Tunnel Address prefix Next hop Flag bit interfaceidentifier (Destination/Mask) (Next hop) (Flag) (Interface) (Tunnel ID) 0.0.0.0/0 120.0.0.2 SU Port 1 0 × 0  8.0.0.0/8 120.0.0.2 DU Port 1 0 ×0  9.0.0.0/8  20.0.0.2 DU Port 2 0 × 0  9.1.0.0/16 120.0.0.2 DU Port 3 0× 0 20.0.0.0/8  20.0.0.1 U Port 2 0 × 0

When forwarding a packet based on, for example, the forwarding tableshown in Table 2, the forwarding plane matches a destination address ofthe packet with an address prefix of each forwarding entry in theforwarding table to determine a matched forwarding entry, and determinesa route of the packet based on the matched forwarding entry. Currently,the forwarding plane usually determines a route according to a longestmatch rule. To be specific, the forwarding plane determines a forwardingentry with a longest mask from the forwarding entry that matches thedestination address, and determines the route of the packet based on theforwarding entry with a longest mask. In other words, it is equivalentto selecting a route corresponding to a long mask. The address prefix(English: prefix) may include two parts: an address and a mask. Forexample, a format of the address prefix is an Internet Protocol (IP)address/mask.

For example, if the destination address of the packet is 9.1.1.18, theforwarding plane matches the destination address 9.1.1.18 with anaddress prefix of each entry in Table 2 in an order of masks from longto short. When determining that an address prefix 9.1.0.0/16 matches thedestination address 9.1.1.18, the forwarding plane no longer continuesmatching, but determines an entry corresponding to the address prefix9.1.0.0/16, and determines a route based on a next hop 120.0.0.2corresponding to the entry, to be specific, forwards the packet to thenext hop 120.0.0.2.

However, the inventor finds, through research, that in some scenarios,the route that is of the packet and determined based on the forwardingentry with a longest mask is often not an optimal route. For example, ina scenario shown in FIG. 1, a metropolitan area network includes arouter A and a router B. An Internet service provider (ISP) 1 includes arouter C and a router D, and an ISP 2 includes a router E and a routerF. In addition, the ISP 1 advertises an address prefix 9.0.0.0/8 to themetropolitan area network, and the ISP 1 also advertises an addressprefix 9.1.0.0/16 to the ISP 2. The address prefix is advertised to themetropolitan area network by using the ISP 2. An address prefix of aserver is 9.1.1.18/24. When a user terminal needs to send a packet whosedestination address is 9.1.1.18, the router A sends the packet to therouter B, and the router B sends, based on the forwarding table shown inTable 2, the packet to a corresponding next-hop address 120.0.0.2, thatis, an address of the router F, so that the packet is sent to the ISP 2,and finally is sent, by using the router E, the router D, and the routerC, to the server connected to the ISP 1. However, because a routeforwarded from the ISP 2 has more costs, higher charging, poorertransmission quality, or the like, the route for forwarding the packetto the ISP 2 may not be an optimal route. However, currently, there isno routing control manner that can be used to select a routecorresponding to a short mask.

To resolve the foregoing technical problems, the embodiments of thepresent invention provide a routing control method, a network device,and a controller, so as to select, by suppressing a route correspondingto a long mask, a route corresponding to a short mask.

The following clearly describes the technical solutions in theembodiments of the present invention with reference to the accompanyingdrawings in the embodiments of the present invention. Apparently, thedescribed embodiments are merely some but not all of the embodiments ofthe present invention. All other embodiments obtained by persons skilledin the art based on the embodiments of the present invention withoutcreative efforts shall fall within the protection scope of the presentinvention.

In the specification, claims, and accompanying drawings of the presentinvention, the terms “first”, “second”, “third”, “fourth”, and the likeare intended to distinguish between similar objects, but do not indicatea specific order or sequence. It should be understood that data termedin such a way is interchangeable in proper circumstances, so that theembodiments described herein can be implemented in other orders than theorder illustrated or described herein. In addition, the terms “include”,“have”, and any other variants thereof mean to cover the non-exclusiveinclusion, for example, a process, method, system, product, or devicethat includes a series of steps or units is not necessarily limited tothose expressly listed steps or units, but may include other steps orunits not expressly listed or inherent to those processes, methods,products, or devices.

Referring to FIG. 2, an embodiment of the present invention provides amethod embodiment of a routing control method. This embodiment may beapplied to a network device.

The network device, such as a control module of the network device, hasa first routing entry and a second routing entry. An address prefix ofthe first routing entry is a first address prefix. An address prefix ofthe second routing entry is a second address prefix. Both the firstaddress prefix and the second address prefix are used to match adestination address of a packet. A mask in the second address prefix isgreater than a mask in the first address prefix. To be specific, a routecorresponding to the first routing entry is a route corresponding to ashort mask, and a route corresponding to the second routing entry is aroute corresponding to a long mask. In addition, a network segment towhich the second address prefix belongs is a network segment U1, and anetwork segment to which the first address prefix belongs is a networksegment U2. The network segment U1 is a subset of the network segmentU2. In other words, the network segment U2 includes the network segmentU1. To be specific, an IP address belonging to the network segment U2certainly belongs to the network segment U1, but an IP address belongingto the network segment U1 may belong to the network segment U2, or maynot belong to the network segment U2. The network segment mentioned inthis embodiment of the present invention is a network segment having alargest range.

For example, the first address prefix may be 9.0.0.0/8, and the secondaddress prefix may be 9.1.0.0/16. It can be learned that a mask 16 isgreater than a mask 8. In addition, a network segment to which9.1.0.0/16 belongs is a network segment 9.1.0.0-9.1.255.255, a networksegment to which 9.0.0.0/8 belongs is a network segment9.0.0.0-9.255.255.255, and the network segment 9.1.0.0-9.1.255.255 is asubset of the network segment 9.0.0.0-9.255.255.255. In addition,because the network segment to which the second address prefix belongsis the subset of the network segment to which the first address prefixbelongs, the destination address of the packet certainly matches thefirst routing entry if the destination address matches the secondrouting entry. For example, if the destination address of the packet is9.1.1.18, the packet matches both 9.0.0.0/8 and 9.1.0.0/16. It should benoted that the long mask and the short mask mentioned in this embodimentof the present invention are relative to each other. For example, forthe masks 8 and 16, 16 is a long mask, and 8 is a short mask.

In this embodiment of the present invention, in addition to the addressprefix, the first routing entry and the second routing entry may haveinformation such as a next-hop address and an entry state. The next-hopaddress is used to indicate a next-hop route, the entry state is used toindicate whether a forwarding entry needs to be delivered, and so on.

For example, the network device may be a forwarding device 01 shown inFIG. 3, and the forwarding device 01 is separately connected to aforwarding device 02 and a forwarding device 03. The first routing entryand the second routing entry may be shown in Table 3. A next-hop addressof the first routing entry is an address of the forwarding device 02. Tobe specific, the first routing entry is used to indicate that the packetis to be forwarded to the forwarding device 02. A next-hop address ofthe second routing entry is an address of the forwarding device 03. Tobe specific, the second routing entry is used to indicate that thepacket is to be forwarded to the forwarding device 03. An initial entrystate of each of the first routing entry and the second routing entrymay be a delivery state in an active state, and the delivery state isused to indicate that a forwarding entry is to be delivered. Theforwarding device 01, the forwarding device 02, and the forwardingdevice 03 may be border devices in different networks. For example, theforwarding device 01 may be a border device in a metropolitan areanetwork or a data center (DC) network, the forwarding device 02 may be aborder device in an ISP 1, and the forwarding device 03 may be a borderdevice in an ISP 2.

TABLE 3 Address prefix Next hop Entry state First address Address of theforwarding Delivery state in an prefix device 02 active state Secondaddress Address of the forwarding Delivery state in an prefix device 03active state

The method in this embodiment includes the following steps.

201. The control module of the network device obtains a routesuppression request.

The route suppression request may carry an address match. The addressmatch is used to determine the second routing entry from the firstrouting entry and the second routing entry, so as to determine a routecorresponding to a long mask. The address match may be the first addressprefix or the second address prefix.

The route suppression request may be a packet message sent by a routingcontrol device such as a controller, or may be a configuration commandor the like configured by a user.

202. The control module determines the second routing entry.

The control module may determine the second routing entry based on theaddress match.

When the control module determines the second routing entry, adetermining rule may be that a mask is greater than a mask in theaddress match, and that an address prefix is totally or partially thesame as the address match. For example, the address match is the secondaddress prefix, such as 9.1.0.0/16. The control module determines, basedon 9.1.0.0/16, that a mask 16 is greater than a mask 8, and that theaddress prefix of the second routing entry is totally the same as9.1.0.0/16, so as to determine the second routing entry.

Alternatively, the determining rule may be that a mask is greater than amask in the address match, and that a network segment to which anaddress prefix belongs is a subset of a network segment to which theaddress match belongs. For example, the address match is the firstaddress prefix, such as 9.0.0.0/8. The control module determines that amask 16 is greater than a mask 8, and that the network segment to whichthe address prefix of the second routing entry belongs is a subset of anetwork segment to which 9.0.0.0/8 belongs, so as to determine thesecond routing entry.

203. The control module sets a state of the second routing entry to anon-delivery state, where the non-delivery state is used to indicatethat the second routing entry does not need to be delivered to aforwarding table.

In this embodiment of the present invention, after determining thesecond routing entry, the control module sets a state of the secondrouting entry, to suppress the route corresponding to the second routingentry, that is, the route corresponding to the long mask. A routingentry is periodically delivered to the forwarding table. Therefore,after the state of the second routing entry is set to the non-deliverystate, the second routing entry is not delivered to the forwarding tablein next delivery of a routing entry. The forwarding table is located ina forwarding module corresponding to the control module. Therefore, whena packet is to be forwarded, the forwarding module does not forward thepacket based on the route corresponding to the second routing entry.

When the state of the second routing entry is set to the non-deliverystate, the second routing entry may be set to an in-active (In-Active)state, or the second routing entry may be set to a rib-only (Rib-Only)state in an active state. For example, as shown in Table 4, the secondrouting entry is set to the in-active or rib-only state. The rib-onlystate is a state in which storage is performed only in a routing table,and indicates that a routing entry does not need to be delivered to theforwarding table of the forwarding module.

TABLE 4 Address prefix Next hop Entry state First address Address of theforwarding Delivery state in an prefix device 02 active state Secondaddress Address of the forwarding In-active or rib-only prefix device 03state

It can be learned from the foregoing technical solutions that, in thisembodiment of the present invention, the network device has the firstrouting entry and the second routing entry, the address prefix of thefirst routing entry is the first address prefix, and the address prefixof the second routing entry is the second address prefix. The mask inthe second address prefix is greater than the mask in the first addressprefix. To be specific, the route corresponding to the second routingentry is the route corresponding to the long mask. In addition, thenetwork segment to which the second address prefix belongs is the subsetof the network segment to which the first address prefix belongs. Afterobtaining the route suppression request, the control module of thenetwork device can determine the second routing entry, and set the stateof the second routing entry to the non-delivery state to indicate thatthe second routing entry does not need to be delivered to the forwardingtable. The route corresponding to the second routing entry is the routecorresponding to the long mask. Therefore, when a packet is to beforwarded, the route corresponding to the long mask is not selected forthe packet based on the second routing entry, so as to select, bysuppressing the route corresponding to the long mask, the routecorresponding to the short mask.

This embodiment of the present invention may be applied to a pluralityof forwarding scenarios. In different forwarding scenarios, the networkdevice is separately corresponding to different devices. Details aredescribed below.

In a first forwarding scenario, the network device is a physicalforwarding device. The physical forwarding device is a forwarding devicethat has a dedicated hardware structure, such as a router or a switchthat has a dedicated hardware structure. The control module is a controlmodule of the physical forwarding device. FIG. 4 shows an exampleforwarding scenario in the first forwarding scenario. The forwardingscenario includes a physical controller and a physical forwardingdevice. A control module of the physical forwarding device receives aroute suppression request sent by the physical controller. The physicalcontroller is a controller that has a dedicated hardware structure, suchas a main control board or a control card.

In a second forwarding scenario, the network device is a first virtualmachine deployed on a general physical server, and the control module isa control module of the first virtual machine. In actual, in thisscenario, a virtualization technology is used to perform virtualizationto obtain a virtual machine (VM) that runs a program used to provide afunction of a forwarding device. The virtual machine is the networkdevice, and a control module of the virtual machine is the controlmodule of the network device.

The virtualization technology is briefly described below: A generalphysical server can be virtualized into a plurality of logical computersby using the virtualization technology, and each logical computer is onevirtual machine on the general physical server. The virtual machines mayrun different operating systems. Therefore, an application program ofeach virtual machine may run within space of an operating systemindependent of another operating system. To be specific, a virtualmachine is a complete computer system that is simulated by usingsoftware, that has a function of a complete hardware system, and thatruns in a totally isolated environment.

FIG. 5 shows an example forwarding scenario in the second forwardingscenario. The forwarding scenario includes a virtual machine 01 and avirtual machine 02. The virtual machine 01 runs a program used toprovide a function of a controller. The virtual machine 02 runs aprogram used to provide a function of a forwarding device. A controlmodule of the virtual machine 02 receives a route suppression requestsent by the virtual machine 01.

It should be noted that, alternatively, the virtual machine 01 and thevirtual machine 02 may be deployed on different general physicalservers.

In a third forwarding scenario, the network device includes a secondvirtual machine deployed on a general physical server, and the controlmodule is the second virtual machine. In actual, in this scenario, avirtualization technology is used to perform virtualization to obtain avirtual machine that runs a program used to provide a function of acontrol module of a forwarding device. The virtual machine is thecontrol module. The network device includes the control module and aforwarding module. The forwarding module provides a packet forwardingfunction, and may be independently deployed on the virtual machine ofthe general physical server, or may be directly deployed on the generalphysical server, or may be deployed on a dedicated physical hardwaredevice.

FIG. 6 shows an example forwarding scenario in the third forwardingscenario. The forwarding scenario includes a virtual machine 03, avirtual machine 04, and a forwarding module. The virtual machine 03 runsa program used to provide a function of a controller. The virtualmachine 04 runs a program used to provide a function of a control moduleof a forwarding device. The virtual machine 04 receives a routesuppression request sent by the virtual machine 03, and delivers arouting entry to the forwarding module. The forwarding module may be anindependent virtual machine.

In this embodiment of the present invention, to avoid impact on packetforwarding, before step 203 of setting a state of the second routingentry to a non-delivery state, whether the first routing entry needs tobe delivered to the forwarding table may be further determined. If thefirst routing entry needs to be delivered to the forwarding table, step203 continues to be performed. Specifically, in this embodiment of thepresent invention, before step 203, the method may further include:determining, by the control module, that the first routing entry is in adelivery state in an active state. The control module may determine thefirst routing entry based on the address match. The network segment towhich the second address prefix belongs is the subset of the networksegment to which the first address prefix belongs. Therefore, even ifthe second routing entry is not delivered to the forwarding table, theforwarding module corresponding to the control module may forward thepacket at least based on the route corresponding to the first routingentry, so as to avoid a case in which the packet cannot be forwarded.Alternatively, if in this embodiment of the present invention, it isdetermined that the first routing entry does not need to be delivered tothe forwarding table, for example, the first routing entry is in anin-active state or a rib-only state, step 203 may not be performed inthis embodiment of the present invention, so as to ensure that packetforwarding is not affected.

For example, in a topology shown in FIG. 3, an address match obtained bya control module of the forwarding device 01 is the first addressprefix, and the control module of the forwarding device 01 determinesthe first routing entry based on the first address prefix. If thecontrol module of the forwarding device 01 determines that the firstrouting entry is in the delivery state in the active state, the controlmodule performs step 203, to be specific, sets the state of the secondrouting entry to the non-delivery state. Therefore, even if thedestination address of the packet matches both the second routing entryand the first routing entry, a forwarding module of the forwardingdevice 01 does not forward the packet to the forwarding device 03 basedon the route corresponding to the second routing entry, but may forwardthe packet to the forwarding device 02 based on a forwarding entrycorresponding to the first routing entry. If the control module of theforwarding device 01 determines that the first routing entry is in anin-active state or a rib-only state, the control module does not performstep 203. Therefore, the forwarding module of the forwarding device 01forwards the packet to the forwarding device 03 based on the routecorresponding to the second routing entry.

In this embodiment of the present invention, after step 203 in which thecontrol module sets a state of the second routing entry, the method mayfurther include: delivering, by the control module, the first routingentry to the forwarding table. The second routing entry is not deliveredto the forwarding table, so that the forwarding module corresponding tothe control module selects, based on the first routing entry, the routecorresponding to the short mask.

In this embodiment of the present invention, the control module mayreceive a route suppression request sent by a routing control device.The routing control device may be a controller in software-definednetworking (SDN). The routing control device may be a network managementdevice, a traffic analysis server, an orchestrator, or the like innon-SDN. The following describes another embodiment of a routing controlmethod by using a controller side as an execution entity.

Referring to FIG. 7, an embodiment of the present invention providesanother method embodiment of a routing control method. This embodimentmay be applied to a controller.

701. The controller delivers a first routing entry and a second routingentry to a control module of a network device, where an address prefixof the first routing entry is a first address prefix, an address prefixof the second routing entry is a second address prefix, a networksegment to which the second address prefix belongs is a subset of anetwork segment to which the first address prefix belongs, and a mask inthe second address prefix is greater than a mask in the first addressprefix.

After calculating the first routing entry and the second routing entry,the controller may deliver the calculated entries to the control module.After receiving the first routing entry and the second routing entry,the control module may store the first routing entry and the secondrouting entry in the network device.

702. The controller determines the second routing entry.

The controller may automatically determine, based on the first routingentry and the second routing entry, that the second routing entry needsto be suppressed; or may determine, by detecting a suppression operationperformed by a user, that the second routing entry needs to besuppressed.

703. The controller sends a route suppression request to the controlmodule, where the route suppression request is used to instruct thecontrol module to set a state of the second routing entry to anon-delivery state, and the non-delivery state is used to indicate thatthe second routing entry does not need to be delivered to a forwardingtable. The route suppression request may carry an address match, and thecontrol module determines the second routing entry based on the addressmatch. For related content in this embodiment, refer to that in theembodiment corresponding to FIG. 2. Details are not described herein.

In this embodiment of the present invention, the controller may be acontroller that has a dedicated hardware structure, and the controllerthat has a dedicated hardware structure may be a device, a main controlboard, a control card, or the like that has a dedicated hardwarestructure. Alternatively, the controller may be a controller implementedby installing software on a general physical server, or a virtualmachine deployed on a general physical server, that is, a virtualmachine that is obtained by performing virtualization by using avirtualization technology and that runs a program used to provide afunction of a controller. The controller may be applied to any one ofthe forwarding scenarios in FIG. 4 to FIG. 6.

In this embodiment of the present invention, alternatively, thecontroller may not send the route suppression request to the controlmodule. After determining the second routing entry, the controller doesnot deliver the second routing entry to the control module in step 701,so that a route corresponding to a long mask can also be suppressed.

In this embodiment of the present invention, a Border Gateway Protocol(BGP) flow specification (FlowSpec) message may be extended to add theaddress match to the message. Details are described below.

Currently, the BGP Flow Spec message is used to control attack traffic.The message includes network layer reachability information (NLRI) andan extended community attribute. The RFC (Request For Comments) 5575defines 12 commonly-used traffic matching rules, for example, includinga destination address, a source address, an IP number, and a portnumber. The 12 rules are encapsulated in the NLRI of the message. Inaddition, the RFC 5575 defines four commonly-used traffic processingbehaviors, for example, including discarding traffic, rate limiting, andredirecting traffic to a virtual private network (VPN). The fourprocessing behaviors are carried in the extended community attribute.

In this embodiment of the present invention, the route suppressionrequest may be specifically a BGP FlowSpec message, NLRI of the BGPFlowSpec message carries the address match, and an extended communityattribute of the BGP FlowSpec message carries a suppression actioncorresponding to the address match. For example, the suppression actionmay instruct to set the state of the second routing entry to anin-active state or a rib-only state. Therefore, after receiving the BGPFlowSpec message, the control module can obtain the address match fromthe NLRI of the message, and obtain the suppression action from theextended community attribute of the message, so as to set the state ofthe second routing entry to the non-delivery state based on thesuppression action. The address match may be the first address prefix orthe second address prefix.

For example, as shown in Table 5, when a type is TBD 1, the addressmatch is the first address prefix, and the TBD 1 instructs to determinethe second routing entry based on the first address prefix and set thestate of the second routing entry to a rib-only state. TBD 2 instructsto determine the second routing entry based on the first address prefixand set the state of the second routing entry to an in-active state.

TABLE 5 Type Extended communityattribute Actual action TBD 1 Set aspecific route to a Determine the second routing rib-only state entrybased on the first address prefix, and set the state of the secondrouting entry to a rib-only state TBD 2 Set a specific route to anDetermine the second routing in-active state entry based on the firstaddress prefix, and set the state of the second routing entry to anin-active state

A route corresponding to the second routing entry is a specific route ofa route corresponding to the first routing entry. TBD represents to bedefined (to be defined). After the Internet Engineering Task Force(IETF) formally allocates a value, the TBD uses the value specified bythe IETF.

Alternatively, the route suppression request may be a configurationcommand, and the configuration command carries the address match and asuppression action corresponding to the address match. The configurationcommand may be obtained after the network device performs localconfiguration, or may be sent by another device to the control module.For example, the another device sends the configuration command to thecontrol module by using the Netconf protocol, to use the configurationcommand as a policy used when the control module delivers a routingentry. The control module sets the state of the second routing entry tothe non-delivery state based on the suppression action in theconfiguration command. The address match may be the first address prefixor the second address prefix.

In this embodiment of the present invention, after the state of thesecond routing entry is set, the state of the second routing entry maybe further restored, so that the second routing entry can be deliveredto the forwarding table. For example, when a state of the first routingentry changes from a delivery state in an active state to an in-activestate or a rib-only state, the control module may restore the state ofthe second routing entry to a delivery state in an active state. Foranother example, the control module restores, based on a suppressioncancellation request or a configuration command, the state of the secondrouting entry to a delivery state in an active state. For example, thecontrol module sets the state of the second routing entry to anin-active state or a rib-only state after receiving an extended BGP FlowSpec update message, and sets the state of the second routing entry tothe delivery state in the active state after receiving an extended BGPFlow Spec cancellation message.

In this embodiment of the present invention, the address match is thefirst address prefix, and in addition to the second routing entry, itcan be further determined that a route corresponding to a third routingentry is a route corresponding to a long mask. To be specific, thenetwork device further has the third routing entry, an address prefix ofthe third routing entry is a third address prefix, a network segment towhich the third address prefix belongs is also a subset of the networksegment to which the first address prefix belongs, and a mask in thethird address prefix is also greater than the mask in the first addressprefix. In this case, in this embodiment of the present invention, astate of the third routing entry may be set to a non-delivery state, sothat the third routing entry does not need to be delivered to theforwarding table; or a state of the third routing entry may not bechanged, so that the third routing entry can still be delivered to theforwarding table. Description is separately provided below.

Optionally, the method further includes: determining, by the controlmodule, the third routing entry based on the address match; and setting,by the control module, the state of the third routing entry to thenon-delivery state, so that the third routing entry does not need to bedelivered to the forwarding table. For example, the first address prefixis 9.0.0.0/8, the second address prefix is 9.1.0.0/16, and the thirdaddress prefix is 9.2.0.0/16. The control module may further set thethird routing entry to an in-active state or a rib-only state. To bespecific, in this embodiment, when it is determined, based on the firstaddress prefix, that both the route corresponding to the second routingentry and the route corresponding to the third routing entry are routescorresponding to a long mask, both of the two routes corresponding to along mask may be suppressed.

Optionally, the method further includes: obtaining, by the controlmodule, a subnet range match; and determining, by the control module,the second routing entry based on the address match and the subnet rangematch in 202. For example, the first address prefix is 9.0.0.0/8, thesecond address prefix is 9.1.0.0/16, the third address prefix is9.2.0.0/16, and the subnet match may be 9.1.0.0. The second routingentry may be determined based on the first address prefix and the subnetmatch. To be specific, in this embodiment, when it is determined, basedon the first address prefix, that both the route corresponding to thesecond routing entry and the route corresponding to the third routingentry are routes corresponding to a long mask, a more specific subnetmay be further specified, so that only the route corresponding to thesecond routing entry is suppressed, and the route corresponding to thethird routing entry is not suppressed.

The following describes this embodiment of the present invention byusing a specific scenario.

Referring to FIG. 8, an embodiment of the present invention providesanother method embodiment of a routing control method. This embodimentmay be applied to a router B shown in FIG. 9.

In a topology shown in FIG. 9, a metropolitan area network includes arouter A and the router B. An ISP 1 includes a router C and a router D,and an ISP 2 includes a router E and a router F. In addition, the ISP 1advertises an address prefix 9.0.0.0/8 to the metropolitan area network,and the ISP 1 also advertises an address prefix 9.1.0.0/16 to the ISP 2.The address prefix is advertised to the metropolitan area network byusing the ISP 2. The router B has the routing table shown in Table 1.

801. A controller (not shown in the figure) identifies that there is anentry corresponding to 9.0.0.0/8 and an entry corresponding to9.1.0.0/16 in Table 1 of the router B, and generates a prompt messagefor a user.

The message may indicate that a route corresponding to 9.1.0.0/16 is aspecific route of a route corresponding to 9.0.0.0/8.

802. The controller determines that a route corresponding to 9.1.0.0/16needs to be suppressed, and generates an extended BGP Flow Spec updatemessage, where NLRI of the message carries 9.0.0.0/8, and an extendedcommunity attribute carries a suppression action, for example, the TBD 1or the TBD 2 shown in Table 5.

A manager may formulate a routing control policy based on the promptmessage displayed in step 801, to be specific, the user accesses adestination address of a network segment 9.1.0.0-9.1.255.255 by usingthe metropolitan area network, and forwards a packet at the ISP 1direction, that is, suppresses the route corresponding to 9.1.0.0/16.The controller generates the extended BGP Flow Spec update message basedon the policy.

803. The controller sends the generated message to the router B.

804. After receiving the message, the router B obtains 9.0.0.0/8 and thesuppression action from the message.

805. The router B traverses Table 1 to determine the entry correspondingto 9.0.0.0/8; determines whether a state of the entry is a deliverystate in an active state; and performs step 806 if the state of theentry is the delivery state in the active state; or if the state of theentry is not the delivery state in the active state, may end aprocedure, or generate a forwarding table based on the local routingtable.

806. The router B traverses Table 1 to determine, based on 9.0.0.0/8, anaddress 9.1.0.0/16 that satisfies a requirement. The requirement is thata mask is greater than 8, and that a network segment to which an addressprefix belongs is a subset of a network segment to which 9.0.0.0/8belongs.

807. The router B determines the routing entry corresponding to9.1.0.0/16, and sets a state of the routing entry to an in-active stateor a rib-only state based on the suppression action. For example, thesuppression action is TBD 1, and the state of the routing entry is setto a rib-only state.

808. The router B delivers a routing entry to the forwarding table basedon a state of each routing entry in the modified Table 1. In themodified Table 1, the state of the routing entry corresponding to9.1.0.0/16 is an in-active state or a rib-only state. Therefore, therouting entry is not delivered to the forwarding table, but the routingentry corresponding to 9.0.0.0/8 is delivered to the forwarding table.

809. The router B receives a packet whose destination address is9.1.1.18, and forwards, based on a forwarding entry corresponding to9.0.0.0/8, the packet to a corresponding next-hop address 20.0.0.2, thatis, an address of the router C, so that the packet is sent to the ISP 1,and finally is sent to a server connected to the ISP 1.

Steps 804 to 808 are performed by a control module of the router B, andstep 809 is performed by a forwarding module of the router B.

It can be learned that, in this embodiment, when accessing a destinationaddress of a network segment 9.1.0.0-9.1.255.255 by using themetropolitan area network, the user can forward the packet at an ISP 1direction, so as to select, by suppressing a route corresponding to along mask, a route corresponding to a short mask.

The foregoing describes the method embodiment of the routing controlmethod in the embodiments of the present invention. The followingdescribes related apparatuses in the embodiments of the presentinvention from a perspective of a modular functional entity.

Referring to FIG. 10, an embodiment of the present invention provides anapparatus embodiment of a network device. A network device 100 in thisembodiment has a first routing entry and a second routing entry, anaddress prefix of the first routing entry is a first address prefix, anaddress prefix of the second routing entry is a second address prefix, anetwork segment to which the second address prefix belongs is a subsetof a network segment to which the first address prefix belongs, and amask in the second address prefix is greater than a mask in the firstaddress prefix.

The network device 100 includes a control module 101. The control module101 includes an obtaining unit 1011, a determining unit 1012, and asetting unit 1013.

The obtaining unit 1011 is configured to obtain a route suppressionrequest.

The determining unit 1012 is configured to determine the second routingentry.

The setting unit 1013 is configured to set a state of the second routingentry to a non-delivery state. The non-delivery state is used toindicate that the second routing entry does not need to be delivered toa forwarding table.

For example, the network device 100 shown in FIG. 10 may be configuredto perform the method shown in FIG. 2. Specifically, the obtaining unit1011 may be configured to perform step 201 in FIG. 2, the determiningunit 1012 may be configured to perform step 202 in FIG. 2, and thesetting unit 1013 may be configured to perform step 203 in FIG. 2.

Optionally, the setting unit 1013 is specifically configured to: set thesecond routing entry to an in-active state, or set the second routingentry to a rib-only state in an active state.

Optionally, the route suppression request is a Border Gateway ProtocolBGP flow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, and the addressmatch is the first address prefix or the second address prefix. Thesetting unit 1013 is specifically configured to set the state of thesecond routing entry to the non-delivery state based on the suppressionaction.

Optionally, the route suppression request is a configuration command,and the configuration command carries an address match and a suppressionaction corresponding to the address match. The setting unit 1013 isspecifically configured to set the state of the second routing entry tothe non-delivery state based on the suppression action. The addressmatch is the first address prefix or the second address prefix.

Optionally, the determining unit 1012 is further configured to: beforethe setting unit 1013 sets the state of the second routing entry to thenon-delivery state, determine that the first routing entry is in adelivery state in an active state.

Optionally, the network device 100 further includes a delivery unit. Thedelivery unit is configured to deliver the first routing entry to theforwarding table after the setting unit 1013 sets the state of thesecond routing entry to the non-delivery state.

Optionally, the network device 100 is a physical forwarding device, andthe control module 101 is a control module of the physical forwardingdevice; or the network device 100 is a first virtual machine deployed ona general physical server, and the control module 101 is a controlmodule of the first virtual machine; or the network device 100 includesa second virtual machine deployed on a general physical server, and thecontrol module 101 is the second virtual machine.

It should be noted that, for various specific implementations of thenetwork device 100 in this embodiment, refer to the detailed descriptionof the embodiment shown in FIG. 2. Details are not described herein.

Referring to FIG. 11, an embodiment of the present invention provides anapparatus embodiment of a controller.

A controller 110 in this embodiment includes a delivery unit 111, adetermining unit 112, and a sending unit 113.

The delivery unit 111 is configured to deliver a first routing entry anda second routing entry to a control module of a network device. Anaddress prefix of the first routing entry is a first address prefix, anaddress prefix of the second routing entry is a second address prefix, anetwork segment to which the second address prefix belongs is a subsetof a network segment to which the first address prefix belongs, and amask in the second address prefix is greater than a mask in the firstaddress prefix.

The determining unit 112 is configured to determine the second routingentry.

The sending unit 113 is configured to send a route suppression requestto the control module. The route suppression request is used to instructthe control module to set a state of the second routing entry to anon-delivery state, and the non-delivery state is used to indicate thatthe second routing entry does not need to be delivered to a forwardingtable.

For example, the controller 110 shown in FIG. 11 may be configured toperform the method shown in FIG. 7. Specifically, the delivery unit 111may be configured to perform step 701 in FIG. 7, the determining unit112 may be configured to perform step 702 in FIG. 7, and the sendingunit 113 may be configured to perform step 703 in FIG. 7.

Optionally, the route suppression request is used to instruct thecontrol module to set the second routing entry to an in-active state, orset the second routing entry to a rib-only state in an active state.

Optionally, the route suppression request is a Border Gateway ProtocolBGP flow specification FlowSpec message, network layer reachabilityinformation NLRI of the BGP FlowSpec message carries an address match,an extended community attribute of the BGP FlowSpec message carries asuppression action corresponding to the address match, the suppressionaction is used to instruct the control module to set the state of thesecond routing entry to the non-delivery state based on the suppressionaction, and the address match is the first address prefix or the secondaddress prefix.

Optionally, the route suppression request is a configuration command,the configuration command carries an address match and a suppressionaction corresponding to the address match, the suppression action isused to instruct the control module to set the state of the secondrouting entry to the non-delivery state based on the suppression action,and the address match is the first address prefix or the second addressprefix.

Optionally, the controller is a controller that has a dedicated hardwarestructure, a controller implemented by installing software on a generalphysical server, or a virtual machine deployed on a general physicalserver.

It should be noted that, for various specific implementations of thecontroller 110 in this embodiment, refer to the detailed description ofthe embodiment shown in FIG. 7. Details are not described herein.

Referring to FIG. 12, an embodiment of the present invention provides asystem embodiment of a network system. In this embodiment, the systemincludes a network device 100 and a controller 110. The network device100 may be a network device in any one of the foregoing implementations,and the controller 110 may be a controller in any one of the foregoingimplementations.

For various specific implementations of the controller 100 and thecontroller 110 in this embodiment, refer to the detailed description ofthe embodiments shown in FIG. 2, FIG. 7, FIG. 10, and FIG. 11. Detailsare not described in this embodiment.

The foregoing describes the related apparatuses in the embodiments ofthe present invention from the perspective of the modular functionalentity. The following describes related apparatuses in the embodimentsof the present invention from a perspective of hardware processing.

Referring to FIG. 13, an embodiment of the present invention providesanother apparatus embodiment of a network device. In this embodiment, anetwork device 1300 has a first routing entry and a second routingentry, an address prefix of the first routing entry is a first addressprefix, an address prefix of the second routing entry is a secondaddress prefix, a network segment to which the second address prefixbelongs is a subset of a network segment to which the first addressprefix belongs, and a mask in the second address prefix is greater thana mask in the first address prefix.

The network device 1300 in this embodiment specifically includes acontrol module, a communications interface (Communications Interface)1302, a memory (memory) 1303, and a communications bus 1304. The controlmodule includes a processor (processor) 1301.

The processor 1301, the communications interface 1302, and the memory1303 complete communication with each other by using the bus 1304.

The processor 1301 is configured to execute a program 1305.

Specifically, the program 1305 may include program code, and the programcode includes a computer operation instruction.

The processor 1301 may be a central processing unit CPU, anapplication-specific integrated circuit ASIC (Application-SpecificIntegrated Circuit), or one or more integrated circuits configured toimplement this embodiment of this application.

The memory 1303 is configured to store the program 1305. The memory 1303may include a high-speed RAM memory, and may further include anon-volatile memory (non-volatile memory), for example, at least onedisk memory. The program 1305 is used to perform the following steps:

obtaining a route suppression request;

determining the second routing entry; and

setting a state of the second routing entry to a non-delivery state,where the non-delivery state is used to indicate that the second routingentry does not need to be delivered to a forwarding table.

For specific implementation of the steps in the program 1305, refer toimplementations of corresponding steps in the embodiment shown in FIG.2. Details are not described herein.

The functional units of the network device 1300 provided in thisembodiment may be specific implementation based on functions of themethod embodiment shown in FIG. 2 and the apparatus embodiment shown inFIG. 10. Definition and description of terms are consistent with thosein the method embodiment shown in FIG. 2 and the apparatus embodimentshown in FIG. 10. Details are not described herein.

Referring to FIG. 14, an embodiment of the present invention providesanother apparatus embodiment of a controller.

A controller 1400 in this embodiment specifically includes a processor(processor) 1401, a communications interface (Communications Interface)1402, a memory (memory) 1403, and a communications bus 1404.

The processor 1401, the communications interface 1402, and the memory1403 complete communication with each other by using the bus 1404.

The processor 1401 is configured to execute a program 1405.

Specifically, the program 1405 may include program code, and the programcode includes a computer operation instruction.

The processor 1401 may be a central processing unit CPU, anapplication-specific integrated circuit ASIC (Application-SpecificIntegrated Circuit), or one or more integrated circuits configured toimplement this embodiment of this application.

The memory 1403 is configured to store the program 1405. The memory 1403may include a high-speed RAM memory, and may further include anon-volatile memory (non-volatile memory), for example, at least onedisk memory. The program 1405 is used to perform the following steps:

delivering a first routing entry and a second routing entry to a controlmodule of a network device, where an address prefix of the first routingentry is a first address prefix, an address prefix of the second routingentry is a second address prefix, a network segment to which the secondaddress prefix belongs is a subset of a network segment to which thefirst address prefix belongs, and a mask in the second address prefix isgreater than a mask in the first address prefix;

determining the second routing entry; and

sending a route suppression request to the control module, where theroute suppression request is used to instruct the control module to seta state of the second routing entry to a non-delivery state, and thenon-delivery state is used to indicate that the second routing entrydoes not need to be delivered to a forwarding table.

For specific implementation of the steps in the program 1405, refer toimplementations of corresponding steps in the embodiment shown in FIG.7. Details are not described herein.

The functional units of the network device 1400 provided in thisembodiment may be specific implementation based on functions of themethod embodiment shown in FIG. 7 and the apparatus embodiment shown inFIG. 11. Definition and description of terms are consistent with thosein the method embodiment shown in FIG. 7 and the apparatus embodimentshown in FIG. 11. Details are not described herein.

It may be clearly understood by persons skilled in the art that, for thepurpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, refer to acorresponding process in the foregoing method embodiments. Details arenot described herein again.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, the unit division ismerely logical function division and may be other division in actualimplementation. For example, a plurality of units or components may becombined or integrated into another system, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented by using some interfaces. The indirect couplings orcommunication connections between the apparatuses or units may beimplemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of the presentinvention may be integrated into one processing unit, or each of theunits may exist alone physically, or two or more units are integratedinto one unit. The integrated unit may be implemented in a form ofhardware, or may be implemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of the presentinvention essentially, or the part contributing to the prior art, or allor some of the technical solutions may be implemented in the form of asoftware product. The computer software product is stored in a storagemedium and includes several instructions for instructing a computerdevice (which may be a personal computer, a server, a network device, orthe like) to perform all or some of the steps of the methods describedin the embodiments of the present invention. The foregoing storagemedium includes any medium that can store program code, such as a USBflash drive, a removable hard disk, a read-only memory (ROM, Read-OnlyMemory), a random access memory (RAM, Random Access Memory), a magneticdisk, or an optical disc.

The foregoing embodiments are merely intended for describing thetechnical solutions of the present invention, but not for limiting thepresent invention. Although the present invention is described in detailwith reference to the foregoing embodiments, persons of ordinary skillin the art should understand that they may still make modifications tothe technical solutions described in the foregoing embodiments or makeequivalent replacements to some technical features thereof, withoutdeparting from the spirit and scope of the technical solutions of theembodiments of the present invention.

1. A routing control method, comprising: obtaining, by a network device,a route suppression request, wherein the network device includes a firstrouting entry and a second routing entry, an address prefix of the firstrouting entry includes a first address prefix, an address prefix of thesecond routing entry includes a second address prefix, a network segmentto which the second address prefix belongs is a subset of a networksegment to which the first address prefix belongs, a mask in the secondaddress prefix is greater than a mask in the first address prefix;determining, by the network device, the second routing entry; andsetting, by the network device, a state of the second routing entry to anon-delivery state, wherein the non-delivery state is used to indicatethat the second routing entry does not need to be delivered to aforwarding table.
 2. The method according to claim 1, wherein thesetting, by the network device, a state of the second routing entry to anon-delivery state comprises: setting, by the network device, the stateof the second routing entry to an inactive state, or setting the stateof the second routing entry to a rib-only state in an active state. 3.The method according to claim 1, wherein: the route suppression requestis a Border Gateway Protocol (BGP) flow specification (FlowSpec)message, network layer reachability information (NLRI) of the BGPFlowSpec message carries an address match, an extended communityattribute of the BGP FlowSpec message carries a suppression actioncorresponding to the address match, and the address match includes thefirst address prefix or the second address prefix; and the setting, bythe network device, a state of the second routing entry to anon-delivery state comprises: setting, by the network device, the stateof the second routing entry to the non-delivery state based on thesuppression action.
 4. The method according to claim 1, wherein theroute suppression request includes a configuration command, theconfiguration command carries an address match and a suppression actioncorresponding to the address match, and the address match includes thefirst address prefix or the second address prefix; and the setting, bythe network device, a state of the second routing entry to anon-delivery state comprises: setting, by the network device, the stateof the second routing entry to the non-delivery state based on thesuppression action.
 5. The method according to claim 1, wherein beforethe setting, by the network device, a state of the second routing entryto a non-delivery state, the method further comprises: determining, bythe network device, that the first routing entry is in a delivery statein an active state.
 6. The method according to claim 5, wherein afterthe setting, by the network device, a state of the second routing entryto a non-delivery state, the method further comprises: delivering, bythe network device, the first routing entry to the forwarding table. 7.A routing control method, comprising: delivering, by a controller, afirst routing entry and a second routing entry to a network device,wherein an address prefix of the first routing entry is a first addressprefix, an address prefix of the second routing entry is a secondaddress prefix, a network segment to which the second address prefixbelongs is a subset of a network segment to which the first addressprefix belongs, and a mask in the second address prefix is greater thana mask in the first address prefix; determining, by the controller, thesecond routing entry; and sending, by the controller, a routesuppression request to the network device, wherein the route suppressionrequest is used to instruct the network device to set a state of thesecond routing entry to a non-delivery state, and the non-delivery stateis used to indicate that the second routing entry does not need to bedelivered to a forwarding table.
 8. The method according to claim 7,wherein the route suppression request is used to instruct the networkdevice to set the second routing entry to an in-active state, or set thesecond routing entry to a rib-only state in an active state.
 9. Themethod according to claim 7, wherein the route suppression request is aBorder Gateway Protocol (BGP) flow specification (FlowSpec) message,network layer reachability information (NLRI) of the BGP FlowSpecmessage carries an address match, an extended community attribute of theBGP FlowSpec message carries a suppression action corresponding to theaddress match, the suppression action is used to instruct the networkdevice to set the state of the second routing entry to the non-deliverystate based on the suppression action, and the address match is thefirst address prefix or the second address prefix.
 10. The methodaccording to claim 7, wherein the route suppression request includes aconfiguration command, the configuration command carries an addressmatch and a suppression action corresponding to the address match, thesuppression action is used to instruct the network device to set thestate of the second routing entry to the non-delivery state based on thesuppression action, and the address match includes the first addressprefix or the second address prefix.
 11. A network system, comprising: anetwork device; and a controller configured to: deliver a first routingentry and a second routing entry to the network device, wherein anaddress prefix of the first routing entry includes a first addressprefix, an address prefix of the second routing entry includes a secondaddress prefix, a network segment to which the second address prefixbelongs is a subset of a network segment to which the first addressprefix belongs, and a mask in the second address prefix is greater thana mask in the first address prefix; determine the second routing entry;and send a route suppression request to the network device; wherein thenetwork device is configured to: obtain the route suppression request;determine the second routing entry; and set a state of the secondrouting entry to a non-delivery state, wherein the non-delivery state isused to indicate that the second routing entry does not need to bedelivered to a forwarding table.
 12. The network system according toclaim 11, wherein the network device is further configured to: set thestate of the second routing entry to an inactive state, or setting thestate of the second routing entry to a rib-only state in an activestate.
 13. The network system according to claim 11, wherein the routesuppression request is a Border Gateway Protocol (BGP) flowspecification (FlowSpec) message, network layer reachability information(NLRI) of the BGP FlowSpec message carries an address match, an extendedcommunity attribute of the BGP FlowSpec message carries a suppressionaction corresponding to the address match, and the address match is thefirst address prefix or the second address prefix; and wherein thenetwork device is further configured to: set the state of the secondrouting entry to the non-delivery state based on the suppression action.14. The network system according to claim 11, wherein the routesuppression request includes a configuration command, the configurationcommand carries an address match and a suppression action correspondingto the address match, and the address match includes the first addressprefix or the second address prefix; and wherein the network device isfurther configured to: set the state of the second routing entry to thenon-delivery state based on the suppression action.